const {connection,mysqlDao} = require('../utils/jdbc-connection')
const BaseDao = require("./base-dao");

/**
 * 博客操作
 */
class AlbumDao extends BaseDao {
    constructor() {
        super();
    }

    /**
     * 数据库插入相册
     * @param Album
     * @returns {Promise<unknown>}
     */
    insertAlbum (Album) {
        const {title,content,description,address,cover,albumList,userId,createTime} = Album
        let sql = 'insert into album(album_title,album_description,album_address,album_cover,album_list,user_id,create_time) values(?,?,?,?,?,?,?)'
        return connection(sql,[title,description,address,cover,albumList,userId,createTime])
    }

    /**
     * 获取相册
     * @returns {Promise<unknown>}
     */
    queryAlbumList(){
        let sql = 'select * from album'
        return connection(sql,[])
    }

    /**
     * 根据id查询相册详情
     * @param id
     * @returns {Promise<unknown>}
     */
    queryAlbumById(id){
        let sql = 'select * from album where id = ?'
        return connection(sql,[id])
    }
}

module.exports = AlbumDao;
